<!-- 优惠券统计 -->
<template>
  <div class="couponStatistics">
    <h3>优惠券统计</h3>
    <div class="listBox">
      <div v-for="(item, index) in list" :key="index" class="listItem">
        <div>
          <p>{{ item.name }}</p>
          <div class="num">
            <span v-if="item.dit" style="font-size:16px;font-weight: normal">{{ item.dit }}</span>
            {{ form[item.filed] }}
          </div>
          <div style="margin-top:10px;">
            <img :src="item.img" alt="" style="width: 56px;height: 17px;">
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getCouponInfo } from "@/api/home";
export default {
  name: "CouponStatistics",
  data() {
    return {
      list: [
        { name: "生成数量", filed: "totalCount",img:require("@/assets/home/scsl.png")},
        { name: "使用数量", filed: "usedCount",img:require("@/assets/home/sysl.png")},
        { name: "过期数量", filed: "outTimeCount",img:require("@/assets/home/sysl.png")},
        { name: "过期金额", filed: "outTimeAmount", dit: "￥" ,img:require("@/assets/home/gqje.png")},
        { name: "使用金额", filed: "usedAmount", dit: "￥",img:require("@/assets/home/gqje.png")},
        { name: "核销率", filed: "usedAmountRate" ,img:require("@/assets/home/hxe.png")},
      ],
      form: {
        totalCount: 0,
        usedCount: 0,
        outTimeCount: 0,
        outTimeAmount: 0,
        usedAmount: 0,
        usedAmountRate: 0
      }
    };
  },
  created() {
    this.getCouponInfo();
  },
  methods: {
    getCouponInfo() {
      getCouponInfo({}).then(res => {
        this.form = { ...res.data };
      });
    }
  }
};
</script>

<style lang="scss">
.couponStatistics {
  display: grid;
  grid-gap: 10px;
  grid-template-rows: 30px 1fr;
  height: 100%;
  background: #fff;
  border-radius: 5px;
  padding: 20px 15px;

  .listBox {
    display: flex;
    justify-content: space-around;
    align-items: center;

    .listItem {
      p {
        color: #859da9;
        text-align: center;
      }

      .num {
        text-align: center;
        font-weight: 700;
        font-style: normal;
        color: #344650;
        font-size: 28px;
        margin-top: 10px;
      }
    }
  }
}
</style>
